﻿<%@ Page Language="C#" AutoEventWireup="true" 
CodeBehind="EstructuraCompraReadForm.aspx.cs" 
Inherits="UILGestion.ObraAdmin.EstructuraCompras.EstructuraCompraReadForm" %>
<%@ Register Assembly="WebLib" Namespace="WebLib" TagPrefix="lib" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
   


<asp:Panel ID="agrupadoECItemParentPanel" runat="server" Height="480px" >
  <asp:Panel ID="agrupadoECItemPanel" runat="server"  Height="480px"  Width="1000px"
   Style="background-color:#DDDDDD;border:solid 1px Gray;color:Black">
   
  
           
           <asp:UpdatePanel ID="partirUpdatePanel" runat="server" UpdateMode="Conditional">
            <ContentTemplate>


                <asp:Panel ID="Panel5" runat="server" CssClass="Heading secTitle AreaHeading ms-crm-List-Header " >
                Agrupar Recurso
                </asp:Panel>

                <asp:Panel ID="Panel8" runat="server"  class="ms-crm-Form-Body" Height="430px" >
                 <input id="idEstructuraCostoPartir" type="hidden"  runat="server" />
                               <input id="idRecursoList" type="hidden"  runat="server" />
                               <lib:Input id="idRecursoNewList" type="hidden"  ReadOnly="true" Width="0" runat="server" />
                               
                               <input id="simbolMoneda" type="hidden"  runat="server" />
                               <input id="idformView" type="hidden"  runat="server" />
                               <input id="simbolOBRADOL" type="hidden"  runat="server" />
                               

                <asp:UpdatePanel ID="totalesUpdatePanel" runat="server" UpdateMode="Conditional">
            <ContentTemplate>
          
          <table width="100%">
          <tr>
          <td  align="left" >
          <table >
          <tr>
          <td>Tipo de Cambio:</td>
          <td><asp:Label ID="tipoCambioLBL" runat="server" Text=""></asp:Label></td>
          </tr>
          </table>
          </td>
          <td align="right">
          
            
<table  class="PanelTotales" >
          
            <tr>
                <td align="right" width="150px">
                    &nbsp;Total Recurso:</td>
                <td>
                
                    <asp:Label ID="TotalRecursoLabel" runat="server"></asp:Label>
                </td>
            </tr>
              <tr>
                <td align="right" width="150px">
                    Total detalle:</td>
                <td>
                    <asp:Label ID="TotalDetalleLabel" runat="server"></asp:Label>
                </td>
            </tr>

            <tr>
                <td align="right" width="150px">
                    Saldo:</td>
                <td>
                    <asp:Label ID="saldoLabel" runat="server" Text=""></asp:Label>
                </td>
            </tr>
            </table>
            </td>
          </tr>
          </table>
            </ContentTemplate>
            </asp:UpdatePanel>                                             
 
        

            
<asp:TabContainer ID="AgrupadoTabContainer" runat="server" Width="100%" ActiveTabIndex="0">
<asp:TabPanel runat="server" HeaderText="Recursos" ID="recursosAgrTabPanel">

<ContentTemplate>


            <asp:LinkButton ID="LinkButtonAgr4" runat="server" />
            <asp:LinkButton ID="LinkButton7" runat="server" />
            <asp:ModalPopupExtender ID="AddRecursoECItemPopup" runat="server" 
            BackgroundCssClass="modalBackground"
             CancelControlID="cancelarAddButton" 
            DropShadow="True" DynamicServicePath="" Enabled="True" 
            OkControlID="LinkButtonAgr4" 
            PopupControlID="addRecurso2ParentPanel" 
            PopupDragHandleControlID="addRecurso2Panel" 
            TargetControlID="LinkButton7" />
            
            <asp:Panel ID="Panel15" runat="server" Height="300px" ScrollBars="Vertical" BackColor="White" 
    BorderColor="LightSteelBlue" BorderStyle="Solid" BorderWidth="1px"   >
    <asp:UpdatePanel ID="itemAgrupadoUpdatePanel" runat="server" UpdateMode="Conditional">
    <ContentTemplate>

<table>
<tr><td>Moneda:</td>
<td><asp:DropDownList ID="monedaDDL" runat="server" AutoPostBack="True" 
        onselectedindexchanged="monedaDDL_SelectedIndexChanged" Width="200px"></asp:DropDownList>
        
        </td>
        
        
        <td><asp:Button ID="agrupadoSelectBTN" runat="server" CssClass="ms-crm-List-Header" 
            OnClick="addRecursosAgrupado" Text="Agregar Recursos" />
            </td></tr>
            </table>

    <asp:GridView ID="itemAgrupadoGridView" 
       Runat="server" 
       AutoGenerateColumns="False" 
       DataKeyNames="idInternal"  
      SkinID="GridView"
     
><Columns>
<asp:BoundField DataField="presupuesto" HeaderText="Presp." ><HeaderStyle Width="35px" /></asp:BoundField>
            <asp:BoundField DataField="partida" HeaderText="Partida" ><HeaderStyle Width="250px" /></asp:BoundField>
            <asp:BoundField DataField="codigo" HeaderText="Codigo" ><HeaderStyle Width="55px" /></asp:BoundField>
            <asp:BoundField DataField="descripcion" HeaderText="Descripcion"><HeaderStyle Width="250px" /></asp:BoundField>
            <asp:BoundField DataField="unidad" HeaderText="Unid." ><HeaderStyle Width="35px" /></asp:BoundField>
            <asp:BoundField DataField="cantidadStr" HeaderText="Cant." ><ItemStyle HorizontalAlign="Right" Width="75px" /></asp:BoundField>
            <asp:BoundField DataField="precioStr" HeaderText="Precio" ><ItemStyle HorizontalAlign="Right" Width="95px" /></asp:BoundField>
            <asp:BoundField DataField="totalStr" HeaderText="Disponible" ><ItemStyle HorizontalAlign="Right" Width="95px" /></asp:BoundField>
            <asp:TemplateField><ItemTemplate>
                <asp:ImageButton ID="lnkRemove" runat="server" BorderColor="Control" 
                    CommandArgument='<%# Eval("idInternal")%>' ImageUrl="~/Images/delete.gif" 
                    OnClick="DeleteAgrupadoItem" 
                    OnClientClick="return confirm('Usted quiere eliminar?.El Recurso sera  devuelto a la estructura')" />
                        </ItemTemplate></asp:TemplateField></Columns>
                        
                        </asp:GridView>
                        </ContentTemplate>
                        </asp:UpdatePanel>
                        
                        </asp:Panel>
                        
                        </ContentTemplate>
                        </asp:TabPanel>

<asp:TabPanel runat="server" HeaderText="Nuevos Recursos" ID="recursosnewTabPanel">
<ContentTemplate>

<asp:Button ID="REAddFromOC" runat="server" Text="Agregar Desde O/C" OnClick="addRecursosFromOC" 
CssClass="ms-crm-List-Header" />
<asp:LinkButton ID="LinkButton8" runat="server" />
<asp:ModalPopupExtender ID="ModalPopupExtenderOC" runat="server" 
            BackgroundCssClass="modalBackground"
             CancelControlID="cancelAddFromOCBTN" 
            DropShadow="True" 
            DynamicServicePath="" 
            Enabled="True" 
            x="0"
            y="0"
            PopupControlID="AddFromOCPanelPanel" 
            PopupDragHandleControlID="AddFromOCPanel" 
            TargetControlID="LinkButton8" />
            <asp:Panel ID="Panel16" runat="server" Height="310px" ScrollBars="Vertical" BackColor="White" 
                       BorderColor="LightSteelBlue" BorderStyle="Solid" BorderWidth="1px"   >
                       
                       <asp:UpdatePanel ID="newrecursoUpdatePanel" runat="server" UpdateMode="Conditional">
                       <ContentTemplate>
                       <asp:GridView ID="itemGridView" 
       Runat="server" 
       AutoGenerateColumns="False" 
       DataKeyNames="idInternal"  
       ShowFooter = "True"       
     SkinID="GridView">
     <Columns>
     <asp:TemplateField HeaderText="Codigo">
     <ItemTemplate><asp:Label ID="codigoLabel" runat="server" BackColor="Transparent" Text='<%# Eval("codigo")%>' > </asp:Label>
     </ItemTemplate><EditItemTemplate>
     <asp:Label ID="codigoLabel" runat="server" BackColor="Transparent" Text='<%# Eval("codigo")%>' > </asp:Label>
     </EditItemTemplate>
     <FooterTemplate>
     <lib:Input ID="codigoInsertTextBox" runat="server" BackColor="Transparent" ReadOnly="true" Width="70px" />
     <lib:Input ID="descripcionInsertTextBox1" runat="server"  BackColor="Transparent"  ReadOnly="true" Width="0px" />
     </FooterTemplate></asp:TemplateField>
     <asp:TemplateField HeaderText="descripcion">
     <ItemTemplate><asp:Label ID="descripcionLabel" runat="server" BackColor="Transparent"  Text='<%# Eval("descripcion")%>'>
     </asp:Label>
     </ItemTemplate>
     <EditItemTemplate>
     <asp:Label ID="descripcionLabel" runat="server" Width="300px"  BackColor="Transparent" Text='<%# Eval("descripcion")%>'> 
     </asp:Label>
     </EditItemTemplate>
     <FooterTemplate>
     <lib:Input ID="descripcionInsertTextBox" runat="server"   
     backcolor="#DFE8F6" DataType="List" method="GetRecursoDisponible"   
      onchange="javascript:validarRecursoAgrupadoInsert(this);" 
                                              OnSelect="SelectRecursoAgrupadoInsert" Width="300px" />
    
    
    </FooterTemplate>
    </asp:TemplateField>
    <asp:TemplateField HeaderText="Unid.">
    
    
    <ItemTemplate><asp:Label ID="unidad45Label" runat="server" BackColor="Transparent" Text='<%# Eval("unidad")%>' Width="35px">                                   </asp:Label></ItemTemplate>
        <EditItemTemplate><asp:Label ID="unidad45Label" runat="server" 
                BackColor="Transparent" Text='<%# Eval("unidad")%>' Width="35px"> </asp:Label></EditItemTemplate>
        <FooterTemplate><lib:Input ID="unidadInsertTextBox" runat="server" 
                BackColor="Transparent" ReadOnly="true" Width="35px" /></FooterTemplate></asp:TemplateField>
    
    <asp:TemplateField HeaderText="Cantidad" ItemStyle-HorizontalAlign="Right" >
    <ItemTemplate><asp:Label ID="cantidadLabel" runat="server" BackColor="Transparent" 
                                      Text='<%# Eval("cantidadStr")%>'/></ItemTemplate>
                                      <FooterTemplate>
                                      <lib:Input ID="cantidadDividirInsertTextBox" runat="server" BackColor="Transparent"  
                                      Width="75px"  onchange="javascript:calcularTotalXCantAgrupado(this);"  DataType="Double"
                                  /></FooterTemplate></asp:TemplateField>
   
   <asp:TemplateField HeaderText="Precio" ItemStyle-HorizontalAlign="Right">
   <ItemTemplate>
                                  <asp:Label ID="precio2Label" runat="server" BackColor="Transparent" Text='<%# Eval("precioStr")%>'>
                                   </asp:Label>
   </ItemTemplate>
                                   <FooterTemplate>
                                   <lib:Input ID="precioInsertTextBox" runat="server" BackColor="Transparent"  Width="95px" 
onchange="javascript:calcularTotalXPrecioAgrupado(this);" DataType="Double"  />
</FooterTemplate>



</asp:TemplateField>
<asp:TemplateField HeaderText="Total" ItemStyle-HorizontalAlign="Right" ><ItemTemplate>
<asp:Label ID="totalLabel" runat="server" BackColor="Transparent"  Text='<%# Eval("totalStr")%>' > 
</asp:Label></ItemTemplate>

<FooterTemplate>

<table width="100%"><tr>
    <td></td><td>
    <b></b><asp:Label 
                        ID="totalBaseInsertLabel" runat="server" BackColor="Transparent" Width="100%" />
                        </div></td></tr>
                        
                        
                        </table>
                        <lib:Input ID="totalInsertTextBox" runat="server" BackColor="Transparent" 
                                   TabIndex="3"   DataType="Double" 
                                  onchange="javascript:calcularPrecioXTotalAgrupado(this);"  />
    </FooterTemplate>
                                     </asp:TemplateField>
                                  <asp:TemplateField>
                                  <ItemTemplate>
                                  
                                  
                                  <asp:ImageButton ID="ImageButton1" runat="server"  Width="15px"
                                OnClientClick="return confirm('Usted quiere eliminar?')" 
                                 CommandArgument='<%# Eval("idInternal")%>'  OnClick="DeleteItem" 
                                  ImageUrl="~/estilos/_imgs/delete.gif" /></ItemTemplate>
                                  
                                  <FooterTemplate>
                                  <asp:Button ID="btnAdd" runat="server" onclick="AddItem"  Text="Añadir"></asp:Button>
                                  </FooterTemplate></asp:TemplateField>
                                  
                                  
                                  
                                  <asp:BoundField DataField="numOrdenCompra" HeaderText="O/C" />
                                  
                                  </Columns>
                                  
                                  
                                  
                                  </asp:GridView></ContentTemplate></asp:UpdatePanel></asp:Panel></ContentTemplate></asp:TabPanel>
                                  
                                  </asp:TabContainer>
  </asp:Panel>


   
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="TabContainer2$recursosTabPanel$AgruparRecursoButton" />
<asp:AsyncPostBackTrigger ControlID="finalizarAgrupadoButton" />
<asp:AsyncPostBackTrigger ControlID="aceptarAddButton" />
<asp:AsyncPostBackTrigger ControlID="addOcItemBTN" />

</Triggers>
               </asp:UpdatePanel>
         
  
 <asp:Panel ID="Panel4" runat="server"   >
        
<table width="100%" >
 <tr  >
               
                <td class=" ms-crm-Dialog-Footer-Right">
               
                     <asp:Button ID="finalizarAgrupadoButton"  runat="server"  Text="Guardar "  CssClass="ms-crm-List-Header"
                      onclick="accionAgrupado_Click"   OnClientClick="return confirm('Usted quiere Agrupar los Recursos?')"
                       
                        />&nbsp;
                    <asp:Button ID="cancelarAgrupadoButton"  runat="server" Text="Cancelar" CssClass="ms-crm-List-Header"
                    
                       
                       />&nbsp;
                   
                </td>
   </tr>


   
</table>

        </asp:Panel>
</asp:Panel>  
 </asp:Panel>
  
    </form>
</body>
</html>
